package com.polito.mad.bikeponyapp.util;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.polito.mad.bikeponyapp.R;

public class newTasksListAdapter extends BaseAdapter{

	private List<String[]>newTasks;
	private Context context;
	public newTasksListAdapter(Context context , List<String[]> newTasks) {
		this.newTasks = new ArrayList<String[]>(newTasks);
		this.context=context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return newTasks.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return newTasks.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null)
		{
			LayoutInflater inflater = (LayoutInflater )context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.newtasks_list_item_layout, parent, false);
		}
		String[] addresses = newTasks.get(position);
		TextView pickupAddressTV = (TextView)convertView.findViewById(R.id.pickup_address);
        pickupAddressTV.setText(addresses[0]);
        TextView deliveryAddressTV = (TextView)convertView.findViewById(R.id.delivery_address);
        deliveryAddressTV.setText(addresses[1]);
        return convertView;
	}

}
